<?php

// +----------------------------------------------------------------------
// |
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2030 http://www.jmzh1688.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: lxl
// +----------------------------------------------------------------------


namespace app\chat\controller;

use think\Controller;
use think\Db;



class Index extends Controller
{
           
    public function index()
    {
       
        return $this->fetch();
    }


    public function sendchat()
    {
        $param = input("post.");
        $param2['create_time'] = time();
        $param2['update_time'] = time();

        $param2['msg'] = $param['msg'] ;
        $param2['isdelete'] = 0 ;
        $param2['openid'] = $param['openid'] ;

        $res = Db::name("chat_msg")->insert($param2);
       
        return json_encode($res);
    }


    public function chatlist()
    {
        $tablename=  config('database.prefix')."chat_msg";
        $sql="select * from (select * from ".$tablename." order by id desc limit 10) t order by id asc;";
        $t=Db::name('jmzhfs_chat_msg');
        $res = $t->query($sql); 
       
        ob_clean();
        return json_encode($res);
    }

    


}
